Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add file storage #1361

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

add file storage #1361

wants to merge 4 commits into from

Conversation

jeriox
Copy link
Contributor

@jeriox jeriox commented Sep 21, 2024

closes #504

  • add CRUD views
  • update deployment docs
  • adapt our own deployment
  • discuss file type restrictions (check with python-magic?)

@coveralls
Copy link

coveralls commented Sep 21, 2024

Coverage Status

coverage: 85.406% (-0.3%) from 85.67%
when pulling d75dd01 on files
into fa2e7d9 on main.

@jeriox jeriox marked this pull request as ready for review September 23, 2024 19:07
@jeriox jeriox changed the title add files app, add models, add view to serve files add file storage Sep 23, 2024
Comment on lines +48 to +55
def __call__(self, request):
response = self.get_response(request)
if (
request.get_host() == urlsplit(settings.GET_USERCONTENT_URL()).netloc
and request.resolver_match.url_name != "document"
):
return redirect(urljoin(settings.GET_SITE_URL(), request.path))
return response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do exactly? (Needs a comment)

Also, am I right to think this is specific to the documents plugin and wouldn't work to deliver e.g. custom logos?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good point. We could move the list of "media views" to the settings

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand what it does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you request the usercontent domain, but on a view that does not serve usercontent (e.g. ephiosusercontent.de/accounts/login), it will redirect you to the same view but on the regular domain. This prevents the app from being served under the content domain, and therefore on the same domain as the usercontent

Comment on lines +27 to +31
response = HttpResponse()
response["X-Accel-Redirect"] = document.file.url
response["Content-Disposition"] = (
"attachment; filename=" + os.path.split(document.file.name)[1]
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need a comment as well. Maybe we can craft this into an AcceleratedMediaResponse class to make it reusable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File storage
3 participants